//
//  UtilsMacros.h
//  OnionHome
//
//  Created by fengjie on 2019/9/13.
//  Copyright © 2019 FengJie. All rights reserved.
//

#define kAppDelegate        ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController

//获取屏幕宽高
#define KScreenWidth ([[UIScreen mainScreen] bounds].size.width)
#define KScreenHeight [[UIScreen mainScreen] bounds].size.height
#define kScreen_Bounds [UIScreen mainScreen].bounds

#define K_StatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height //状态栏高度
#define K_NavBarHeight 44.0
#define K_TabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49) //底部tabbar高度
#define K_TopHeight (K_StatusBarHeight + K_NavBarHeight) //整个导航栏高度


//弱引用
#define kWeakSelf(weakSelf) __weak __typeof(&*self)weakSelf = self;

//调用block回调
#define BlockSafeRun(block, ...) block ? block(__VA_ARGS__) : nil


//-------------------打印日志-------------------------
//DEBUG  模式下打印日志,当前行
#ifdef DEBUG
#define NSLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);

#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define NSLog(format, ...)
#define DLog(...)
#endif

#define DLogFunc DLog(@"%s", __func__)


//显示本地图片
#define IMAGE_NAMED(name) [UIImage imageNamed:name]


// 圆角和加边框
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

// 圆角
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]


//对字符串进行非空判断
#define StrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""] )
//判断手机号长度并且不为空
#define StrValidPhone(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""] && (f.length == 11) )

// 当前系统版本
#define CurrentSystemVersion [[UIDevice currentDevice].systemVersion doubleValue]
